Conversation
1. prefer to be in different zones (soft rule) 2. must not be scheduled on the same node
|
@jiangpengcheng:Thanks for your contribution. For this PR, do we need to update docs? |
|
@jiangpengcheng:Thanks for providing doc info! |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a feature flag to enable default pod anti-affinity for operator-managed pods, ensuring replicas avoid the same node and prefer distinct zones. Key changes:
- Add
AddDefaultAffinityconfig, CLI flag, and Helm value - Implement
GenerateAffinityto inject default anti-affinity rules - Update integration tests and sample manifests to opt out of the new behavior
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/configs.go | Add AddDefaultAffinity global config var |
| main.go | Introduce --add-default-affinity flag and wire through utils |
| controllers/spec/common.go | Implement GenerateAffinity and apply to pod templates |
| charts/function-mesh-operator/values.yaml | Add addDefaultAffinity value under controllerManager |
| charts/function-mesh-operator/templates/controller-manager-deployment.yaml | Pass --add-default-affinity to the controller manager args |
| .ci/tests/integration/e2e_with_tls.yaml | Set addDefaultAffinity=false in Helm install for TLS E2E |
| .ci/tests/integration/cases/python-function/manifests.yaml | Increase replicas for sample to exercise anti-affinity logic |
| .ci/tests/kind.yaml | Add extra worker nodes for zone-based scheduling tests |
Comments suppressed due to low confidence (1)
controllers/spec/common.go:487
- Add unit tests for
GenerateAffinityto verify that both required and preferred anti-affinity rules are correctly added whenAddDefaultAffinityis true and that no rules are added or mutated when false.
func GenerateAffinity(affinity *corev1.Affinity, labels map[string]string) *corev1.Affinity {
| var GlobalBackendConfig = "" | ||
| var GlobalBackendConfigNamespace = "default" | ||
| var NamespacedBackendConfig = "" | ||
| var AddDefaultAffinity = true |
There was a problem hiding this comment.
Will a global flag be too broad? How can we stop adding the default affinity for selected instances or selected namespaces?
There was a problem hiding this comment.
we can add a flag in CRD to disable it for each instance, but it's hard to set the flag per namespace
* [feat] Add default affinities to ensure pods: 1. prefer to be in different zones (soft rule) 2. must not be scheduled on the same node * add test * fix npe * fix vulnerabilities * fix unittest * fix unittest * fix ci * increase kind nodes in ci * fix ci * fix ci * Add a `DisableDefaultAffinity` field to PodPolicy * Update doc
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
Explain here the context, and why you're making that change. What is the problem you're trying to solve.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
Check the box below.
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doc(Please explain why)
doc(If this PR contains doc changes)